import { diff } from 'diff-json';

interface Item {
  key: string;
  type: string
}

export function deepDifInterface(current: object, next: object) {
  const diffs = [];
  const diffResult = diff(current, next);

  const map = {
    remove: '接口已删除',
    add: '新增接口',
    update: '接口有更新'
  }

  diffResult.map((item: Item) => {
    const { key, type } = item;

    diffs.push({
      label: key,
      type,
      description: `${map[type]}`
    });
  });

  return diffs;
};
